package com.apps.MiniChat;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;

public class MenuChat extends Activity implements OnClickListener{
    /** Called when the activity is first created. */
	Button chatButton = null;
	Button optionButton = null;
	Button ExitButton = null;
	private RelativeLayout menuLayout;
	public static int Port =6000;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_menu);
        //Layout Menu
        menuLayout = (RelativeLayout) findViewById(R.id.relativeLayout1);
        ExitButton = (Button) findViewById (R.id.buttonExit);
        ExitButton.setOnClickListener(this);
        chatButton = (Button) findViewById (R.id.buttonChat);
        chatButton.setOnClickListener(this);
        optionButton = (Button) findViewById (R.id.buttonOption);
        optionButton.setOnClickListener(this);
          
	    menuLayout.setVisibility(View.VISIBLE);
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v.getId() == R.id.buttonChat)
		{
			Intent myIntent = new Intent(v.getContext(), MenuConnection.class);
            startActivity(myIntent);
		}
		else if(v.getId() == R.id.buttonOption)
		{
			Intent myIntent = new Intent(this,MenuOption.class);
	    	startActivityForResult(myIntent,1);
		}
		else if(v.getId() == R.id.buttonExit)
		{
			this.finish();
		}
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK)
		{
			Bundle extras = data.getExtras();
			Port = (Integer) extras.get("ServerPort");
			Log.d("Port", Integer.toString(Port));
		}
		else 
		{
			finish();
		}
	}
	
}
